<%@ page language="java" import="java.util.*" import="java.sql.*" import = "orm.*"  pageEncoding="utf-8" errorPage="errorPage.jsp"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<% 	User tea  =(User) session.getAttribute("Teacher");  
	if (tea == null){
		response.sendRedirect(path + "/index.jsp");
	}
%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href = "<%=basePath %>"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>个人信息</title>
<link href="css/tStyles.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
	<% if (request.getAttribute("modifyInfo") != null){%>
	alert("修改成功！");
	<%}%>
	function check(){
		if (document.getElementById("realname").value == ""){
			alert("真实姓名不能为空！！");
			return false;
		}
		if (document.getElementById("phone").value == "") {
			alert("联系电话不能为空！！");
			return false;
		}
		if (isNaN(document.getElementById("phone").value)) {
			alert("联系电话必须为数字型！！");
			return false;
		}
		if (document.getElementById("email").value == "") {
			alert("email不能为空，请填写正确的邮件！！");
			return false;
		}
		var i = document.getElementById("email").value.indexOf("@");
		var j = document.getElementById("email").value.indexOf(".");
		if ((i < 0) || (i - j > 0) || (j < 0)){
			alert("您输入的Email格式不正确，请重新输入！！");
			return false;
		}
		return true;
	}
	function commit(){
		if (check()){
			var opt = confirm("确定修改信息？");
			if (opt == true){
				this.viewInfo.action="manageInfo.do?type=Teacher";
				return this.viewInfo.submit();
			}
			return false;
		}
		return false;
	}
</script>
</head>

<body>
	<!-- CONTAINER START -->
<div id = "container">
<!-- HEADER START -->
        <div id = "top">
        	<div id = "navigation">
            	<html:link page="/teacher/teacher.jsp" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;首页</html:link>
                <html:link page="/teacher/notice.jsp" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;通知</html:link>
                <html:link action="manageQuestions.do?action=startManagement" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;题库</html:link>
                <html:link action="manageKnowledges.do?action=startManagement" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;知识点</html:link>
                <html:link action="manageTemplates.do?action=startManagement" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;试卷模板</html:link>
                <html:link action="gradeManagement.do?action=startMana" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;成绩管理</html:link>
                <html:link page="/teacher/studentMana.jsp" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;学生管理</html:link>
            </div>
  		</div>
        <!-- HEADER END -->
        
    <!-- LOGIN START -->
        <div id = "login">
       	  <div id = "name">
       	  <%=tea.getRealname()%>
          </div>
        	<html:link page="/teacher/teacherInfo.jsp" styleClass="viewInfo">·查询个人信息</html:link>
          	<p><html:link page="/teacher/teaModifyPwd.jsp" styleClass="modifyPwd">·修改密码</html:link></p>
            <p><html:link page="/teacher/letter.jsp" styleClass="letter">·站内信</html:link></p>
            <p><html:link forward="logout" styleClass="logout">·注销登录</html:link></p>
  </div>
        <!-- LOGIN END -->
        
    	<!-- CLOCK START -->
  <div id = "clock">
        	<iframe src="index/clock.html" height="407" width="296" frameborder="0" scrolling="no"
            		marginheight="0" marginwidth="0" id="clockFrame" name="clockFrame"></iframe>
  </div>
        <!-- CLOCK END -->
        
        <!-- MAIN START -->
      	<div id = "main">
        	<div id = "title">≡个人信息≡
            <hr />
            </div>
        	<div id = "register">
				<table class="t2" cellpadding="0" cellspacing="0">
  				<tr>
    				<td height="332" class="td1">
	  				<form name="viewInfo" method="post" action="" onsubmit="javascript:return commit();">
						<table class="t3" cellspacing="0">
  						<tr>
    						<td>用 户 名: *</td>
    						<td style="text-align: center;"><%=tea.getUsername()%></td>
    					</tr>
  						<tr>
    						<td>真实姓名: *</td>
    						<td><input <%if (tea.getRealname() != null){ %>value="<%=tea.getRealname()%>" <%} %> name="realname" id="realname" /></td>
  						</tr>
  						<tr>
    						<td>联系电话: *</td>
    						<td><input <%if (tea.getPhone() != null){ %>value="<%=tea.getPhone()%>" <%} %> name="phone" id="phone" /></td>
  						</tr>
  						<tr>
    						<td>邮 箱: *</td>
    						<td><input <%if (tea.getEmail() != null){ %>value="<%=tea.getEmail()%>" <%} %> name="email" id="email" /></td>
  						</tr>
						</table>
						<table class="t4">
                        	<tr>
                            	<td><input type="submit" name="save" value="确定保存" /></td>
                        		<td><input type="button" name="cancel" value="取消" 
                        		onclick="window.location.href = 'teacher/teacher.jsp'" /></td>
                            </tr>
                        </table>
					</form>	
                    </td>
  				</tr>
				</table>
			</div>
        </div>
   	<!-- MAIN END -->
        
   	<!-- FOOTER START -->
   	<div id = "footer">
  </div>
   	<!-- FOOTER END -->
        
</div>
    <!-- CONTAINER END -->
    
</body>
</html>
